# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gegl

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=r6229.0c1f414
pkgrel=1
pkgdesc="Generic Graphics Library (mingw-w64)"
arch=('any')
url="http://gegl.org/gegl/"
license=("GPL-3.0+" "LGPL-3.0+")
makedepends=(asciidoc
            #"${MINGW_PACKAGE_PREFIX}-ffmpeg"
            "${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
            "${MINGW_PACKAGE_PREFIX}-lua"
            "${MINGW_PACKAGE_PREFIX}-pkg-config"
            "${MINGW_PACKAGE_PREFIX}-python2"
            "${MINGW_PACKAGE_PREFIX}-ruby"
            "${MINGW_PACKAGE_PREFIX}-vala"
            "${MINGW_PACKAGE_PREFIX}-pygobject-devel")
depends=("${MINGW_PACKAGE_PREFIX}-babl-git"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-exiv2"
         "${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-gettext"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk2"
         "${MINGW_PACKAGE_PREFIX}-jasper"
         "${MINGW_PACKAGE_PREFIX}-libjpeg"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-librsvg"
         "${MINGW_PACKAGE_PREFIX}-libspiro"
         "${MINGW_PACKAGE_PREFIX}-libwebp"
         "${MINGW_PACKAGE_PREFIX}-lcms"
         "${MINGW_PACKAGE_PREFIX}-lensfun"
         "${MINGW_PACKAGE_PREFIX}-openexr"
         "${MINGW_PACKAGE_PREFIX}-pango"
         "${MINGW_PACKAGE_PREFIX}-SDL"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
#optdepends=("${MINGW_PACKAGE_PREFIX}-openexr: for using the openexr plugin"
#            "${MINGW_PACKAGE_PREFIX}-ffmpeg: for using the ffmpeg plugin"
#            "${MINGW_PACKAGE_PREFIX}-librsvg: for using the svg plugin"
#            "${MINGW_PACKAGE_PREFIX}-jasper: for using the jasper plugin")
options=('strip' 'staticlibs')
source=("${_realname}"::"git://git.gnome.org/gegl"
        0001-give-cc-to-gir-scanner.all.patch)
sha1sums=('SKIP'
          'aabcead7c7a81b875840cbd233826ff4920c042f')

pkgver() {
  cd "$srcdir/$_realname"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd ${srcdir}/${_realname}
  patch -p1 -i ${srcdir}/0001-give-cc-to-gir-scanner.all.patch
  autoreconf --force --install --verbose
}

build() {
  export lt_cv_deplibs_check_method='pass_all'
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  PKG_CONFIG=${MINGW_PREFIX}/bin/pkg-config.exe \
  "${srcdir}"/${_realname-}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --disable-static \
    --with-sdl \
    --with-openexr \
    --with-librsvg \
    --with-jasper \
    --without-libavformat \
    --disable-docs \
    --with-vala \
    --enable-introspection
  
  CC=gcc make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  rm "${pkgdir}${MINGW_PREFIX}"/lib/gegl-*/*.dll.a
}
